<?php
require_once("mysqlUser/mysql.php");

class secWeaponBase
{
	public static $table = "secweaponparts";
	
	private $name;
	private $level;
	private $cost;
	private $bullet;
	private $pow;
	private $speed;
	private $maxdur;
	
	//四个不同强化等级下，不同变量的加成
	private $incCost = array(1,1.2,1.5,2);
	private $incPow = array(1,1.2,1.5,2);
	private $incMaxdur = array(1,1.2,1.5,2);
	
	//////////////////////////////////////////
	public function __set($name, $value) 
	{
		if ( isset( $this->$name ) ){}
		else $this->$name = $value;
	}
	
	public function __get($name) 
	{
		if( isset( $this->$name ) ) return $this->$name;
		else trigger_error( $name . ' variables undefined',  E_USER_NOTICE );
	}
	
	public function secWeaponBase($id,$inc)
	{
		$command = "select * from ".secWeaponBase::$table." where id=$id";
		$result = mysql::run($command);
		$data=mysql_fetch_array($result);
		
		$this->name = $data["name"];
		$this->level = $data["level"];
		$this->cost = floor($data["cost"]*$this->incCost[$inc]);
		$this->bullet = $data["bullet"];
		$this->pow = floor($data["pow"]*$this->incPow[$inc]);
		$this->speed = $data["speed"];
		$this->maxdur = floor($data["maxdur"]*$this->incMaxdur[$inc]);
	}
}
?>